# 3 编写一个UDP的聊天程序，客户端和服务器端能互相聊天应答；

from socket import *

ADDR = ('127.0.0.1', 8888)
server = socket(AF_INET, SOCK_DGRAM)
server.bind(ADDR)
print("服务器已经启动")
setdefaulttimeout(20)
while True:
    data, client = server.recvfrom(1024)
    print("接受客户端的消息", data.decode("utf-8"))
    info = input('>>>')
    server.sendto(info.encode(), client)


server.close()